package Visitor;

import Entities.Advantages.DecreaseBallSpeed;
import Entities.Advantages.DecreaseBarSize;
import Entities.Advantages.IAdvantage;
import Entities.Advantages.IncreaseBallSpeed;
import Entities.Advantages.IncreaseBarSize;
import Entities.Ball;
import Entities.Bar;
import Entities.Boundary;
import Entities.Brick;
import Entities.Drawable;
import Entities.Hinder;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;

public class GraphicPaintVisitor implements IVisitor {

    private Graphics g;
    private Image ballImage;

    public GraphicPaintVisitor(Graphics g) {
        try {
            this.g = g;
            ballImage = ImageIO.read(new File("ball.png"));
        } catch (IOException ex) {
            Logger.getLogger(GraphicPaintVisitor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public Drawable visit(Bar bar) {
        g.drawRect(bar.getX(), bar.getY(), bar.getWidth(), bar.getHeight());
        return null;
    }

    @Override
    public Drawable visit(Ball ball) {
        if (ball.getDx() == 0 && ball.getDy() == 0) {
            g.drawString("Press SPACE", 170, 200);
        }
        g.drawImage(ballImage, ball.getX(), ball.getY(), null);
        return null;
    }

    @Override
    public Drawable visit(Boundary boundary) {
        g.drawRect(boundary.getX(), boundary.getY(), boundary.getWidth(), boundary.getHeight());
        return null;
    }

    @Override
    public Drawable visit(IAdvantage advantage) {
        g.fillRect(advantage.getX(), advantage.getY(), advantage.getWidth(), advantage.getHeight());
        return null;
    }

    @Override
    public Drawable visit(Brick brick) {
        g.drawRect(brick.getX(), brick.getY(), brick.getWidth(), brick.getHeight());
        return null;
    }

    @Override
    public Drawable visit(Drawable drawable) {
        return null;
    }

    @Override
    public Drawable visit(Hinder hinder) {
        return null;
    }

    @Override
    public Drawable visit(DecreaseBarSize dicreaseBarSize) {
        return null;
    }

    @Override
    public Drawable visit(IncreaseBarSize increaseBarSize) {
        return null;
    }

    @Override
    public Drawable visit(DecreaseBallSpeed drecreaseBallSpeed) {
        return null;
    }

    @Override
    public Drawable visit(IncreaseBallSpeed increaseBallSpeed) {
        return null;
    }
}
